<%@page import="com.dingpeikeji.quickdeer.modules.rentproduct.entity.TDemands"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="REACTSTATUS_WAIT" value="<%=TDemands.REACTSTATUS_WAIT %>" />
<c:set var="REACTSTATUS_DONE" value="<%=TDemands.REACTSTATUS_DONE %>" />
<c:set var="REACTSTATUS_SURE" value="<%=TDemands.REACTSTATUS_SURE %>" />
<c:set var="REACTSTATUS_CANCEL" value="<%=TDemands.REACTSTATUS_CANCEL %>" />
<html>
<head>
<meta name="decorator" content="front" />
<title>定制包车</title>
<link href="${ctxStatic }/xiake/css/list.css" rel='stylesheet'type='text/css' />
<link href="${ctxStatic }/xiake/css/style.css" rel='stylesheet'type='text/css' />
<link href="${ctxStatic }/cityselector/cityselect.css" rel='stylesheet'type='text/css' />
<script type="text/javascript" src="${ctxStatic }/cityselector/cityselect.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=kOQ8j9rd2ATw2R54boLMFUalu3gGNGDO"></script>
<script type="text/javascript">
// 百度地图API功能
function G(id) {
	return document.getElementById(id);
}

var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
	{"input" : "sendAddress"
});

ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
var str = "";
	var _value = e.fromitem.value;
	var value = "";
	if (e.fromitem.index > -1) {
		value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
	}    
	str = "FromItem<br />index = " + e.fromitem.index + "<br />value = " + value;
	
	value = "";
	if (e.toitem.index > -1) {
		_value = e.toitem.value;
		value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
	}    
	str += "<br />ToItem<br />index = " + e.toitem.index + "<br />value = " + value;
	G("searchResultPanel").innerHTML = str;
	var myValue;
	ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
	var _value = e.item.value;
		myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
		G("searchResultPanel").innerHTML ="onconfirm<br />index = " + e.item.index + "<br />myValue = " + myValue;
		
		setPlace();
	});
});
</script>
<script type="text/javascript">
var yes = "${fns:getDictValue('是','yes_no','')}"; // 字典yes_no的“是”
$(function(){
	// 初始化站点选择框
	$.post('${ctxFront}/info/site/siteJson',{spottypes:'0'}, function(data) {
		var allCity = data;//['北京市#001#1|beijing|bj','上海市#002#0|shanghai|sh'];
		new Vcity.CitySelector({input:'departcityName',cityData:allCity});
		new Vcity.CitySelector({input:'destcityName',cityData:allCity});
	});
	
	$('input[name=ispublic]').trigger('change');
	<c:if test="${not empty tDemands.demandid }">
		$('input').attr('disabled','disabled');
		$('textarea').attr('disabled','disabled');
		$('select').attr('disabled','disabled');
	</c:if>
	
});
function check(){
	var msg = '';
	var integer = /^[0-9]*[1-9][0-9]*$/; 
	var money=/^[0-9]*(\.[0-9]{1,2})?$/;
	$('.integer').each(function(){
		var val = $(this).val();
		if(val!='' && !integer.test(val)) {
			$(this).focus();
			msg = '非法';
			return;
		}
	});
	$('.double').each(function(){
		var val = $(this).val();
		if(val!='' && !money.test(val)) {
			$(this).focus();
			msg = '非法';
			return;
		}
	});
	if(msg == ''){
		$('#saveForm').submit();
	}
}
</script>

</head>
<body>
	<input type="hidden" id="menuInfo" value="indexDemands">
	<div class="container font_normal_size">
		<div class="container_navf">
			<c:set var="siderMenuName" value="定制包车"/>
			<%@ include file="/WEB-INF/views/modules/base/siderMenu.jsp"%>
		</div>
		<div class="container_con">
			<form id="saveForm" action="${ctxFront }/rentproduct/demands/save" method="post">
				<div class="container_information  font_normal_size">
					<div>
						<label>出发地:</label>
						<input type="text" id="departcityName" name="departcity.sitename" value="${tDemands.departcity.sitename }" autocomplete="off">
						<input type="hidden" name="departcity.siteid" value="${tDemands.departcity.siteid }">
						<span class="red">*</span>
					</div>
					<div>
						<label for="sendAddress">详细地址:</label>
						<input type="text" id="sendAddress" name="sendAddress" placeholder="街道详细（精确到门牌号） " required="required">
						<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
						<span class="red">*</span>
					</div>
					<div>
						<label>到达地:</label>
						<input type="text" id="destcityName" name="destcity.sitename" value="${tDemands.destcity.sitename }" autocomplete="off">
						<input type="hidden" name="destcity.siteid" value="${tDemands.destcity.siteid }">
						<span class="red">*</span>
					</div>
					<div>
						<label>行程描述:</label>
						<input type="text"  id="modeldesc" name="modeldesc"  value="${tDemands.modeldesc}"/>
					</div>
					<div>
						<label>选择车型:</label>
						<select name="cartype.cargotypeid" style="min-width:380px;height:28px;border:1px solid #dddddd;background-color: #D5D5D5 !important;">
						<c:forEach items="${cargotypeList }" var="cargotype">
							<option value="${cargotype.cargotypeid }" ${tDemands.cartype.cargotypeid==cargotype.cargotypeid?'selected':'' }>${cargotype.typename }</option>
						</c:forEach>
						</select>
						<span class="red">*</span>
					</div>
					<div>
						<label>包车数量:</label>
						<input type="number" id="vehiclenum" name="vehiclenum" class="integer" min="1" value="${tDemands.vehiclenum}"/>
						<span class="red">*</span>
					</div>
					<div>
						<label>用车时间:</label>
						<input id="fromdate" name="fromdate" type="text" readonly="readonly" maxlength="20" class="Wdate"
							value="<fmt:formatDate value="${tDemands.fromdate}" pattern="yyyy-MM-dd HH:mm"/>"
							onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
						<span class="red">*</span>
					</div>
					<div>
						<label>包车天数:</label>
						<input type="number" id="rentdays" name="rentdays" class="integer" min="1" value="${tDemands.rentdays}"/>
						<span class="red">*</span>
					</div>
					<div>
						<label>联系人:</label>
						<input type="text" id="contactor" name="contactor" value="${tDemands.contactor}"/>
						<span class="red">*</span>
					</div>
					<div>
						<label>联系电话:</label>
						<input type="text" id="contactphone" name="contactphone" value="${tDemands.contactphone}"/>
						<span class="red">*</span>
					</div>
					<div style="margin: 10px 0">
						<label style="vertical-align: top;">备注</label>
						<textarea rows="5" name="remarks" maxlength="200">${tDemands.remarks}</textarea>
					</div>
					<c:if test="${not empty reactList }">
						<div style="height:auto;margin:0;padding:0;overflow:hidden;border-width:1px 1px 1px 1px;border-style:solid;border-color:#daf3ff">
							<table style="width:100%;">
								<tr style="background:#daf3ff">
									<th style="text-align:center;width:15%">名称</th>
									<th style="text-align:center;width:15%">总价</th>
									<th style="text-align:center;width:30%">车辆备注</th>
									<th style="text-align:center;width:20%">响应时间</th>
									<th style="text-align:center;width:20%">操作</th>
								</tr>
								<c:forEach items="${reactList }" var="react">
									<tr>
										<td style="text-align:center;">${react.office.abbr }</td>
										<td style="text-align:center;">${react.price }</td>
										<td style="text-align:center;">${react.remarks }</td>
										<td style="text-align:center;"><fmt:formatDate value="${react.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td style="text-align:center;">
											<c:if test="${tDemands.reactstatus ne REACTSTATUS_DONE and tDemands.reactstatus ne REACTSTATUS_CANCEL }">
												<a href="${ctxFront }/rentproduct/demands/book?reactid=${react.reactid}&demandid=${tDemands.demandid}" class="container_table_y2 pointer" style="width:100px;">确认支付</a>
											</c:if>
										</td>
									</tr>
								</c:forEach>
							</table>
						</div>
					</c:if>
					<div style="text-align:center">
						<c:if test="${empty tDemands.demandid }">
							<button class="container_sorder_zf pointer" style="border: none;" type="button" onclick="check();">提交</button>
						</c:if>
						<a class="herfnew"  href="${ctxFront }/rentproduct/demands">查看我的需求</a>
					</div>
					<div class="clear"></div>
				</div>
			</form>
			</div>
		</div>
	<div class="clear"></div>
</body>
</html>